package com.chaos.framework.model.dto.result.data;

import com.chaos.framework.model.dto.result.Result;
import com.chaos.framework.model.enums.ResultEnum;
import lombok.*;
import lombok.experimental.Accessors;

/**
 * @author Jacky
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
public class StringResult extends Result {

    private String data;

    public StringResult(ResultEnum re, String data) {
        this.setCode(re.getCode());
        this.setMsg(re.getMsg());
        this.setData(data);
    }

    public StringResult(Integer code, String msg, String data) {
        this.setCode(code);
        this.setMsg(msg);
        this.setData(data);
    }

    public static StringResult ok(String data) {
        return new StringResult(ResultEnum.OK.getCode(), "success", data);
    }


    public static StringResult error(ResultEnum resultEnum) {
        return new StringResult(resultEnum.getCode(), resultEnum.getMsg(), null);
    }

    public static StringResult error(Integer errorCode, String msg) {
        return new StringResult(errorCode, msg, null);
    }

    public static StringResult error(Integer errorCode, String msg, String data) {
        return new StringResult(errorCode, msg, data);
    }


}
